﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DreamCube.Foundation.Basic.Utility
{
    /// <summary>
    /// 获取表示全局唯一标识符 (GUID)
    /// </summary>
    public static class MyGuid
    {
        /// <summary>
        /// 获取表示全局唯一标识符 (GUID)
        /// 格式：xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
        /// </summary>
        /// <returns></returns>
#if NET20
        public static String To_N(Guid oTargetGuid)
#else 
        public static String To_N(this Guid oTargetGuid)
#endif
        {
            return oTargetGuid.ToString("N");
        }

        /// <summary>
        /// 获取表示全局唯一标识符 (GUID)
        /// 格式：xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 
        /// </summary>
        /// <returns></returns>
#if NET20
        public static String To_D(Guid oTargetGuid)
#else 
        public static String To_D(this Guid oTargetGuid)
#endif
        {
            return oTargetGuid.ToString("D");
        }

        /// <summary>
        /// 获取表示全局唯一标识符 (GUID)
        /// 格式：(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) 
        /// </summary>
        /// <returns></returns>
 #if NET20
        public static String To_P(Guid oTargetGuid)
#else 
        public static String To_P(this Guid oTargetGuid)
#endif
        {
            return oTargetGuid.ToString("P");
        }

        /// <summary>
        /// 获取表示全局唯一标识符 (GUID)
        /// 格式：{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 
        /// </summary>
        /// <returns></returns>
#if NET20
        public static String To_B(Guid oTargetGuid)
#else
        public static String To_B(this Guid oTargetGuid)
#endif
        {
            return oTargetGuid.ToString("B");
        }

        /// <summary>
        /// 括在大括号的 4 个十六进制值，其中第 4 个值是 8 个十六进制值的子集（也括在大括号中）：
        /// {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
#if NET20
        public static String To_X(Guid target)
#else
        public static String To_X(this Guid target)
#endif
        {
            return target.ToString("X");
        }
    }
}
